package com.itheima.pxgl.cotroller;


import com.itheima.pxgl.common.Result;
import com.itheima.pxgl.entity.pojo.Category;
import com.itheima.pxgl.service.ICategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 九尾
 * @since 2024-05-22
 */
@Slf4j
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private ICategoryService categoryService;
    /**
     *获取分类
     * @return
     */
    @GetMapping("")
    public Result<List<Category>> getCategory(){
        log.info("获取所有分类");
        List<Category> list = categoryService.list();
        return Result.success(list);
    }
}
